package com.coco.group.mapper;

import com.coco.group.pojo.TbGroupBuyGoods;
import com.coco.group.vo.GroupGoodsSearchVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @Package: com.coco.group.mapper
 * @Author: 张dy
 * @Date: Created in 2021/7/29 下午 8:01
 */
@Mapper
public interface GroupBuyGoodsMapper {
    void addGroupGoods(TbGroupBuyGoods groupBuyGoods);

    List<TbGroupBuyGoods> findAll();

    List<TbGroupBuyGoods> search(GroupGoodsSearchVo groupGoodsSearchVo);

    /**
     * 查询单条
     * @param goodsId 主键
     * @return
     */
    TbGroupBuyGoods findById(Long goodsId);


    TbGroupBuyGoods findOne(Long id);

    void updateStatus(@Param("id") Long id, @Param("status") String status);

    void deleteGroupGoods(Long id);

    void updateGroupGoods(TbGroupBuyGoods groupBuyGoods);


    /**
     * 查询单条
     * @param id
     * @return
     */
    TbGroupBuyGoods findGoodsById(Long id);

    /**
     * 查询即将拼团的商品加入redis
     * @return
     */
    List<TbGroupBuyGoods> findStartGroupGoods();


    /**
     * 修改spu的参与人数和限量剩余
     * @param gid
     */
    void updateJoinNumAndStock(Long gid);

    /**
     * 添加spu库存
     * @param gid
     * @param num
     */
    void addStock(@Param("gid") Long gid,
                  @Param("num") Integer num);
}
